package fournitures;

public class EpsilonRepository {
	private double[] probvect;
	public EpsilonRepository(double[] probvect){
		this.probvect=probvect;
	}
	public double computeEpsilon(){
		double sum=0.0;
		double var=0.0;
		int M=probvect.length;
		
		for (int i=0;i<M;i++){
			double tmp=probvect[i];
			sum=sum+tmp;
		}
		double mean=sum/(double)M;
		
		for (int i=0;i<M;i++){
			double tmp=probvect[i];
			var=var+(tmp-mean)*(tmp-mean);
		}
		
		double variance=var/(double)M;
		
		double sigma=Math.sqrt(variance);
		return Math.min(1, mean+2*sigma);
	}
}
